<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
cfc('core')->checklogin();
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
	$member=pdo_get('jy_djhome_worker',array('mid'=>$_SESSION['uid']));
	$info=pdo_get('core_members',array('id'=>$_SESSION['uid']));
	if(!$member){
		$member=pdo_get('jy_djhome_member',array('mid'=>$_SESSION['uid']));
		if(!$member){
			$member['user']='no';	
		}else{
			$member['user']='member';
		}
	}else{
		$member['user']='worker';
		$this->model('worker')->check_busy($member['id']);
	}
	$member['nickname']=$info['nickname'];
	$member['avatar']=$info['avatar'];
	$member['credit2']=$info['credit2'];
if($_RQ['op']=='main'){
	$daytime = mktime(0,0,0,date('m'),date('d'),date('Y'));
	$return['daystatus5']=pdo_count('jy_djhome_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>array(5,9),'worker_id'=>$member['id'],'onend_time >'=>$daytime),'id');
	$return['allstatus5']=pdo_count('jy_djhome_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>array(5,9),'worker_id'=>$member['id']),'id');
	$dayfee=pdo_getsum('jy_djhome_order',array('uniacid'=>$_SESSION['uniacid'],'status'=>array(5,9),'worker_id'=>$member['id'],'onend_time >'=>$daytime),'price');
	if($return['pluginset']['fee_price']){
			$daymyfee=$return['pluginset']['fee_price']*$return['daystatus5'];
	}elseif($return['pluginset']['fee_rate']){
			$daymyfee=(100-$return['pluginset']['fee_rate'])*$dayfee/100;
	}
	$return['daymyfee']=$daymyfee;
	$return['dayfee']=$dayfee;
	$return['member']=$member;
	$return['role']=$_SESSION['role'];
	if($return['pluginset']['shenhe_members']){
		foreach($return['pluginset']['shenhe_members'] as $sv){
			if($sv['mid']==$_SESSION['uid']){
				$return['isshenhe_member']=1;
				break;
			}
		}
	}
	set_html('title','会员中心');
	exi($return);
}
if($_RQ['op']=='set'){
	$member=pdo_get('core_members',array('id'=>$_SESSION['uid']));
	if($_RQ['postdata']){
		$postdata=get_postdata();
		if(strlen($postdata['mobile'])!=11){
			exi('手机号输入有误','error');
		}
		$data=array(
				'name'=>$postdata['name'],
				'mobile'=>$postdata['mobile'],
				'avatar'=>$postdata['avatar'],
		);
		$info = pdo_get('jy_djhome_member',array('mid'=>$_SESSION['uid']),'id');
		if($info){
				pdo_update('jy_djhome_member',$data,array('mid'=>$_SESSION['uid']));
				exi('修改成功','','jy_djhome/home/');	
		}else{
				$data['mid']=$_SESSION['uid'];
				$data['uniacid']=$_SESSION['uniacid'];
				$data['createtime']=TIMESTAMP;
				pdo_insert('jy_djhome_member',$data);
				exi('修改成功','','jy_djhome/home/');	
		}
	}
	$member['mobile']=$member['mobile']?intval($member['mobile']):'';
	$member['nickname']=$member1['nickname'];
	$member['avatar']=$member1['avatar'];
	$member['name']=$member1['nickname'];
	$return['member']=$member;
	exi($return);
}